<?php

$con = mysql_connect("localhost", "root", "root");
if (!$con) {
    die("couldn't connect " . mysql_error());
}
mysql_select_db("jianglaifarm", $con);
$result = mysql_query("select * from t_user where login_id = '$_POST[loginId]'");
$flag = true;
while($row = mysql_fetch_array($result))
{
	if($row['login_id']=="$_POST[loginId]"){
		$flag = false;
	}
}
if($flag){
	$sql = "insert into t_user (LOGIN_ID,USER_NAME,PASSWORD,EMAIL) values('$_POST[loginId]','$_POST[userName]',"
	        . "'$_POST[password]','$_POST[email]')";
	if (!mysql_query($sql, $con)) {
	    die('Error: ' . mysql_error());
	}
	header("Location:login.php");
	exit();
}else{
	//echo "注册失败 <a href='regist.html'>返回注册页面</a>";
	header("Location:regist.html");
	exit();
}
mysql_close($con)

?>
